package com.lokyiu.lesson2.domain;

import java.util.ArrayList;
import java.util.List;

public class TryGenerics {
	
	public ArrayList getFruits(){
		ArrayList fruits = new ArrayList();
		fruits.add(new Apple());
		fruits.add(new Orange());
		fruits.add(new Car());
		fruits.add(new MobilePhone());
		return fruits;
	}
	
	public ArrayList<Fruit> getFruits2(){
		ArrayList<Fruit> fruits2 = new ArrayList<Fruit>();
		fruits2.add(new Apple());
		fruits2.add(new Orange());
		return fruits2;
	}
	public static void main(String[] args){
		TryGenerics tg = new TryGenerics();
		ArrayList fs = tg.getFruits();
		
		for(Object x : fs){
			if(x instanceof Fruit){
				System.out.println(x);
			}else{
				System.out.println(x + " (not Fruit)");
			}
		}
	}
	
}
